// Created by lifei on 2020/7/17--17:45.
<template>
    <div class="pager-box" :data-id="pageTem">
        <div class="tips" v-if="showSelectTips">已选中{{selectList.length}}条</div>
        <div v-else></div>
        <div class="pager">
            <el-pagination
                @size-change="changePageSize"
                @current-change="changeCurrentPage"
                :current-page.sync="currentPage"
                layout="total, prev, pager, next, sizes"
                :page-sizes="[10, 20, 50]"
                :page-size="pager.pageSize"
                :total="pager.total"
                background>
            </el-pagination>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'v-pager',
        props: {
            showSelectTips: {
                type: Boolean,
                default: () => false
            },
            selectList: {
                type: Array,
                default: () => []
            },
            pager: {
                type: Object,
                default: () => {
                    return {
                        total: 0, // 总页数
                        currentPage: 1, // 当前页数
                        pageSize: 10 // 每页显示多少条
                    }
                }
            }
        },
        computed: {
            pageTem: function () {
                this.currentPage = this.pager.currentPage
                return this.pager.currentPage
            }
        },
        data() {
            return {
                currentPage: 1,
            }
        },
        methods: {
            changePageSize(val) {
                this.$emit('changePageSize', val)
            },
            changeCurrentPage(val) {
                this.$emit('changeCurrentPage', val)
            },
        }
    }
</script>

<style scoped lang='scss'>
    .pager-box {
        display: flex;
        justify-content: space-between;
        margin-bottom: 12px;

        .pager {
            margin-right: -20px;
        }
    }
</style>
